-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth): add default workspace support for user handling #9099
Conversation
Introduce `defaultWorkspaceId` to improve workspace redirection logic. Updated GraphQL schema, server logic, and frontend components accordingly to prioritize default workspaces when available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR adds default workspace support to improve user redirection during authentication, with the main change being the introduction of a defaultWorkspaceId
field in the UserExists response.
- Added
defaultWorkspaceId
field in/packages/twenty-front/src/modules/auth/graphql/queries/checkUserExists.ts
for workspace prioritization - Updated workspace redirection logic in
/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpGlobalScopeForm.tsx
to prioritize default workspace - Fixed duplicate state setting in
/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
clearSession function - Added explicit workspace domain cookie clearing in session management
- Updated handleVerify to use defaultWorkspace instead of previous selection logic
7 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
@Field(() => String) | ||
defaultWorkspaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider making defaultWorkspaceId optional since a user might not have a default workspace set
packages/twenty-server/src/engine/core-modules/auth/dto/user-exists.entity.ts
Show resolved
Hide resolved
Eliminates redundant setting of `domainConfigurationState` in the `useAuth` hook. This prevents unnecessary operations and ensures cleaner state management.
Refactored the data handling logic for the checkUserExists response to improve readability and maintainability. The changes streamline variable usage and eliminate redundant nesting. Functionality remains unchanged, ensuring proper redirection or mode-switching behavior.
Thanks @AMoreaux for your contribution! |
Introduce
defaultWorkspaceId
to improve workspace redirection logic. Updated GraphQL schema, server logic, and frontend components accordingly to prioritize default workspaces when available.Summary
This PR adds a mechanism to handle and prioritize default workspace selection for users during authentication. It updates the logic in multiple components and services to ensure users are redirected to their default workspaces if no specific selection is provided.
Main changes:
GraphQL Schema Updates:
UserExists
GraphQL entity with a newdefaultWorkspaceId
field to specify the user's default workspace.defaultWorkspaceId
.Client-Side Updates:
useAuth
hook to include logic for managing default workspace redirection.SignInUpGlobalScopeForm
to utilize thedefaultWorkspaceId
.Server-Side Adjustments:
AuthService
to includedefaultWorkspaceId
incheckUserExists
.Tests/Helpers:
UserExists
GraphQL).Subsequent function lifecycle was adjusted to include recheck for workspace token states when performing sign-in flows.